home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_05 / 1n05011a < prev    next >
Text File  |  1990-08-21  |  2KB  |  58 lines

  1. /* compile with -N- -B and -r- options */
  2. #pragma warn -par
  3. #include <dos.h>
  4.  
  5. /* service int 0x7E and send commands to the ai */
  6.  
  7. void interrupt int7e(ibp,idi,isi,ids,ies,
  8.                      idx,icx,ibx,iax)
  9. int ibp,idi,isi,ids,ies,idx,icx,ibx;
  10. int iax; /* bytes in buffer or 0 to initialize */
  11. /* returns iax nonzero if error */
  12. /* initialization returns buffer pointer in icx:ibx */
  13.  
  14. {
  15. #     define MAXBUF 1000
  16.  
  17.       /* real mode buffer */
  18.       static struct {
  19.         short jcobsz;       /* buffer size */
  20.         char pqbuf[MAXBUF]; /* buffer */
  21.       } c_rmb = {MAXBUF};
  22.  
  23.       static void pascal (**pptab)(char *);
  24.       int iloc,nbyts,ncmd;
  25.  
  26.       nbyts = iax; /* get number of bytes in buffer */
  27.       iax = 0; /* say request processed successfully */
  28.  
  29.       if (nbyts <= 0) { /* initialize if requested */
  30.  
  31.         /* make sure ai is installed */
  32.         _AX = 0x3500+0x7F;
  33.         geninterrupt(0x21);
  34.         if (_BX == 0 && _ES == 0) { iax = 1; return; }
  35.  
  36.         /* get address of entry table */
  37.         _AX = 0x0105;
  38.         geninterrupt(0x7F);
  39.         asm jnc initok
  40.         { iax = 1; return; }
  41. initok: ;
  42.         ((int *)&pptab)[0] = _DX; /* table pointer */
  43.         ((int *)&pptab)[1] = _CX;
  44.  
  45.         /* pass back address of real mode buffer */
  46.         ibx = FP_OFF(&c_rmb);
  47.         icx = FP_SEG(&c_rmb);
  48.         return;
  49.       }
  50.  
  51.       /* call ai for each command in the buffer */
  52.       for (iloc = 0; iloc < nbyts;) {
  53.         ncmd = c_rmb.pqbuf[iloc++];
  54.         (*pptab[ncmd])(c_rmb.pqbuf+iloc);
  55.         iloc += 2+c_rmb.pqbuf[iloc];
  56.       }
  57. }
  58.